package com.stedu.mall.goodsservice;

import com.stedu.mall.common.bean.Goods;
import com.stedu.mall.common.service.CategoryService;
import com.stedu.mall.goodsservice.mapper.GoodsMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.math.BigDecimal;

@SpringBootTest
public class GoodsServiceApplicationTests1 {
    @Autowired
    private GoodsMapper goodsMapper;
    @Autowired
    private CategoryService categoryService;

    @Test
    public void test1() {
        System.out.println(goodsMapper.selectById(1).getPicList());
    }

    @Test
    public void test2() {//增删
        //Goods goods = new Goods(506, "niuma", "9876", "33", new BigDecimal(10), new BigDecimal("10.2"), new BigDecimal(3), "red", "3.0.2", 5, 1, 1, 4.7f, 0, null, null);
        Goods goods = new Goods(null, "niuma", "9876", "33", new BigDecimal(10), new BigDecimal("10.2"), new BigDecimal(3), "red", "3.0.2", 5, 1, 1, 4.7f, 0, null, null);
        System.out.println(goodsMapper.insert(goods));
        System.out.println(goods.getId());

    }
    @Test
    public void test3() {//根据条件查
        Goods condition = new Goods();
        condition.setName("诺基亚老人机");
        goodsMapper.selectByCondition(condition).stream().forEach(System.out::println);
    }
    @Test
    public void test4() {//根据条件查
        System.out.println(goodsMapper.selectById(1));
    }
    @Test
    public void test5(){
        Goods goods = new Goods();
        goods.setCategoryId(6);
        goods.setStatus(1);
        goodsMapper.selectByCondition1(goods).forEach(System.out::println);
    }
}
